// 模拟商品数据
var commodityListData = [
    {
        id: '1',
        title: '出售一台笔记本',
        //商品图片
        image: [
            'https://img1.baidu.com/it/u=1058684484,1576085109&fm=253&fmt=auto&app=138&f=JPEG?w=667&h=500',
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg6.baixing.net%2F8ab0b712c0616f19bfdb2bbc33512e83.jpg_xl&refer=http%3A%2F%2Fimg6.baixing.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673183725&t=1ae2542d823bc4e9ad39c0944db42971',
            'https://img1.baidu.com/it/u=4075857316,718479543&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=375'
        ],
        introduce: '因为打算换电脑了，这台笔记本就用不着出售了,便宜卖，价格好商量',
        price: '2499.99',
        userCloudID: '1000'
    },
    {
        id: '2',
        title: '出售一双穿过一次的鞋子',
        image: [
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg10.360buyimg.com%2Fn1%2Fjfs%2Ft1%2F189114%2F39%2F22272%2F197959%2F624313cbEccbcd4cd%2F29cfc3bb398cc0d4.jpg&refer=http%3A%2F%2Fimg10.360buyimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673183906&t=6777fa5f894ee9a85a4d541e90e14c08',
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimgservice.suning.cn%2Fuimg1%2Fb2c%2Fimage%2FsBRCXs6rNIgnKG0YgY2vPA.jpg_800w_800h_4e&refer=http%3A%2F%2Fimgservice.suning.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673183970&t=754842f2f98222ee507001975ce1053a',
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.alicdn.com%2Fbao%2Fuploaded%2Fi3%2F3221079748%2FO1CN01x06e4W2LsdY7lkkXg_%21%210-item_pic.jpg&refer=http%3A%2F%2Fimg.alicdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673183970&t=cfec992c7b288258a983b569041162cc'
        ],
        introduce: '只穿过一次，99新，具有纪念意义，价格好商量',
        price: '141.99',
        userCloudID: '1000'
    },
    {
        id: '3',
        title: '出售一个水杯，寝室水杯太多了',
        image: [
            'https://img1.baidu.com/it/u=1021976495,3132687092&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Frsqiniu.xpw888.com%2Frs%2Fphoto%2F15149%2Fproduct%2F20150818%2F1439868035957.png&refer=http%3A%2F%2Frsqiniu.xpw888.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673184082&t=22e40fcaf34e58cc47c7a522999e2c81',
            'https://img1.baidu.com/it/u=582743967,3563809296&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=889'
        ],
        introduce: '这个水杯很好看，价格便宜出售',
        price: '9.9',
        userCloudID: '1000'
    },
    {
        id: '4',
        title: '出售一个椅子，A校区',
        image: [
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg1.doubanio.com%2Fview%2Fgroup_topic%2Fl%2Fpublic%2Fp493991389.jpg&refer=http%3A%2F%2Fimg1.doubanio.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673184445&t=c41cb50d02e161bdd1fda66841f02a38',
            'https://img1.baidu.com/it/u=582743967,3563809296&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=889'
        ],
        introduce: '只穿过一次，99新，具有纪念意义，价格好商量',
        price: '140.99',
        userCloudID: '1000'
    },
    {
        id: '5',
        title: '出售一舒适的椅子，价格好商量',
        image: [
            'https://img0.baidu.com/it/u=2947112240,3718226548&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
            'https://img1.baidu.com/it/u=582743967,3563809296&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=889'
        ],
        introduce: '只穿过一次，99新，具有纪念意义，价格好商量',
        price: '140.99',
        userCloudID: '1005'
    },
    {
        id: '6',
        title: '出售一块表，爱马仕的,价格好商量',
        image: [
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fgfs17.gomein.net.cn%2FT1s1ViBXhT1RCvBVdK_800.jpg&refer=http%3A%2F%2Fgfs17.gomein.net.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673184519&t=78b8b9579dc80bdc5dcaa23a5562b857',
            'https://img1.baidu.com/it/u=582743967,3563809296&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=889'
        ],
        introduce: '只穿过一次，99新，具有纪念意义，价格好商量',
        price: '140.99',
        userCloudID: '1004'
    },
    {
        id: '7',
        title: '出售一台照相机，不爱这个兴趣了',
        image: [
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.tukuppt.com%2Fphoto-big%2F18%2F02%2F20%2F30%2F43%2F180220304301.jpg&refer=http%3A%2F%2Fimg.tukuppt.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673184586&t=172072baa3f71a487aeda03e9bbfbaf6',
            'https://img1.baidu.com/it/u=582743967,3563809296&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=889'
        ],
        introduce: '只穿过一次，99新，具有纪念意义，价格好商量',
        price: '140.99',
        userCloudID: '1003'
    },
    {
        id: '8',
        title: '出售一个宝宝，99新，无任何损坏',
        image: [
            'https://img2.baidu.com/it/u=1649015354,1843507515&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
            'https://img1.baidu.com/it/u=582743967,3563809296&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=889'
        ],
        introduce: '只穿过一次，99新，具有纪念意义，价格好商量',
        price: '140.99',
        userCloudID: '1001'
    },
    {
        id: '9',
        title: '出售考研的书，本人已上岸，便宜卖，有缘人',
        image: [
            'https://img2.baidu.com/it/u=629479177,438495180&fm=253&fmt=auto&app=138&f=JPEG?w=375&h=500',
            'https://img1.baidu.com/it/u=1231971484,2328276513&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=674',
            'https://img0.baidu.com/it/u=151687053,1458872606&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=450',
            'http://t13.baidu.com/it/u=355305039,3195514550&fm=224&app=112&f=JPEG?w=500&h=500'
        ],
        introduce: '是一些高数等书籍材料',
        price: '20',
        userCloudID: '1002'
    },
    {
        id: '10',
        title: '出售考研的书',
        image: [
            'https://img1.baidu.com/it/u=1945048983,2323028096&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=753',
            'https://img1.baidu.com/it/u=1231971484,2328276513&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=674',
            'https://img0.baidu.com/it/u=151687053,1458872606&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=450',
            'http://t13.baidu.com/it/u=355305039,3195514550&fm=224&app=112&f=JPEG?w=500&h=500'
        ],
        introduce: '是一些高数等书籍材料',
        price: '20',
        userCloudID: '1002'
    },
    {
        id: '11',
        title: '出售考研的书',
        image: [
            'https://img0.baidu.com/it/u=1394002511,2298453138&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=667',
            'https://img2.baidu.com/it/u=629479177,438495180&fm=253&fmt=auto&app=138&f=JPEG?w=375&h=500',
            'https://img1.baidu.com/it/u=1231971484,2328276513&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=674',
            'https://img0.baidu.com/it/u=151687053,1458872606&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=450',
            'http://t13.baidu.com/it/u=355305039,3195514550&fm=224&app=112&f=JPEG?w=500&h=500'
        ],
        introduce: '是一些高数等书籍材料',
        price: '20',
        userCloudID: '1002'
    },
    {
        id: '12',
        title: '出售考研的书',
        image: [
            'https://img2.baidu.com/it/u=595480725,2284295646&fm=253&fmt=auto&app=138&f=JPEG?w=667&h=500',
            'https://img1.baidu.com/it/u=1231971484,2328276513&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=674',
            'https://img0.baidu.com/it/u=151687053,1458872606&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=450',
            'http://t13.baidu.com/it/u=355305039,3195514550&fm=224&app=112&f=JPEG?w=500&h=500'
        ],
        introduce: '是一些高数等书籍材料',
        price: '20',
        userCloudID: '1002'
    },
    {
        id: '13',
        title: '出售考研的书',
        image: [
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw%2Fcad2b835-c5d1-46fd-9766-9b0c34186453%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673332611&t=adbf09bf1f6539fbe2e861b401e04c82',
            'https://img0.baidu.com/it/u=1394002511,2298453138&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=667',
            'https://img2.baidu.com/it/u=629479177,438495180&fm=253&fmt=auto&app=138&f=JPEG?w=375&h=500',
            'https://img1.baidu.com/it/u=1231971484,2328276513&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=674',
            'https://img0.baidu.com/it/u=151687053,1458872606&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=450',
            'http://t13.baidu.com/it/u=355305039,3195514550&fm=224&app=112&f=JPEG?w=500&h=500'
        ],
        introduce: '是一些高数等书籍材料',
        price: '20',
        userCloudID: '1002'
    },
    {
        id: '14',
        title: '出售考研的书',
        image: [
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw%2Fcd5ba9e9-6051-4765-a97d-5813fb9ceec2%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673332611&t=fe60fa1f06b245590f491fe923bfa05d',
            'https://img0.baidu.com/it/u=195662367,1098646879&fm=253&fmt=auto&app=138&f=JPG?w=500&h=409',
            'https://img2.baidu.com/it/u=629479177,438495180&fm=253&fmt=auto&app=138&f=JPEG?w=375&h=500',
            'https://img1.baidu.com/it/u=1231971484,2328276513&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=674',
            'https://img0.baidu.com/it/u=151687053,1458872606&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=450',
            'http://t13.baidu.com/it/u=355305039,3195514550&fm=224&app=112&f=JPEG?w=500&h=500'
        ],
        introduce: '是一些高数等书籍材料',
        price: '20',
        userCloudID: '1002'
    },
    {
        id: '15',
        title: '出售考研的书',
        image: [
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.kaoyan365.cn%2Fuploadfile%2F2019%2F0322%2F20190322015412791.png&refer=http%3A%2F%2Fwww.kaoyan365.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673332361&t=b1dbb22d66fd98472e2f8bacfa0c2115',
            'https://img2.baidu.com/it/u=629479177,438495180&fm=253&fmt=auto&app=138&f=JPEG?w=375&h=500',
            'https://img1.baidu.com/it/u=1231971484,2328276513&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=674',
            'https://img0.baidu.com/it/u=151687053,1458872606&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=450',
            'http://t13.baidu.com/it/u=355305039,3195514550&fm=224&app=112&f=JPEG?w=500&h=500'
        ],
        introduce: '是一些高数等书籍材料',
        price: '20',
        userCloudID: '1002'
    },
    {
        id: '16',
        title: '出售考研的书',
        image: [
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F65d5ec42-314a-40d7-9aef-d8eeae196be3%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673332487&t=e1e64f0ea1e1be53c851b233eec0d3ed',
            'https://img2.baidu.com/it/u=629479177,438495180&fm=253&fmt=auto&app=138&f=JPEG?w=375&h=500',
            'https://img1.baidu.com/it/u=1231971484,2328276513&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=674',
            'https://img0.baidu.com/it/u=151687053,1458872606&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=450',
            'http://t13.baidu.com/it/u=355305039,3195514550&fm=224&app=112&f=JPEG?w=500&h=500'
        ],
        introduce: '是一些高数等书籍材料',
        price: '20',
        userCloudID: '1002'
    },
    {
        id: '17',
        title: '出售考研的书',
        image: [
            'https://img2.baidu.com/it/u=1117334893,3093724414&fm=253&fmt=auto?w=800&h=1066',
            'https://img2.baidu.com/it/u=629479177,438495180&fm=253&fmt=auto&app=138&f=JPEG?w=375&h=500',
            'https://img1.baidu.com/it/u=1231971484,2328276513&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=674',
            'https://img0.baidu.com/it/u=151687053,1458872606&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=450',
            'http://t13.baidu.com/it/u=355305039,3195514550&fm=224&app=112&f=JPEG?w=500&h=500'
        ],
        introduce: '是一些高数等书籍材料',
        price: '20',
        userCloudID: '1002'
    },
    {
        id: '18',
        title: '出售考研的书',
        image: [
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F46dbafa6-d75c-4196-9a62-987d2fef4611%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673332518&t=6ab88e44204e0368da06f870c60e839b',
            'https://img2.baidu.com/it/u=629479177,438495180&fm=253&fmt=auto&app=138&f=JPEG?w=375&h=500',
            'https://img1.baidu.com/it/u=1231971484,2328276513&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=674',
            'https://img0.baidu.com/it/u=151687053,1458872606&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=450',
            'http://t13.baidu.com/it/u=355305039,3195514550&fm=224&app=112&f=JPEG?w=500&h=500'
        ],
        introduce: '是一些高数等书籍材料',
        price: '20',
        userCloudID: '1002'
    },
    {
        id: '19',
        title: '出售考研的书',
        image: [
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw%2Ff2a44e44-dbe9-40ac-8d00-a2c53d788990%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673332537&t=61c5b300ef26956e575d0dbb42699ff2',
            'https://img2.baidu.com/it/u=629479177,438495180&fm=253&fmt=auto&app=138&f=JPEG?w=375&h=500',
            'https://img1.baidu.com/it/u=1231971484,2328276513&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=674',
            'https://img0.baidu.com/it/u=151687053,1458872606&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=450',
            'http://t13.baidu.com/it/u=355305039,3195514550&fm=224&app=112&f=JPEG?w=500&h=500'
        ],
        introduce: '是一些高数等书籍材料',
        price: '20',
        userCloudID: '1002'
    },
    {
        id: '20',
        title: '出售考研的书',
        image: [
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F6f1b3127-51dc-4827-9f13-9085df6927d8%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673332557&t=68b2c1723c13418aaafd45f25791e7e5',
            'https://img2.baidu.com/it/u=629479177,438495180&fm=253&fmt=auto&app=138&f=JPEG?w=375&h=500',
            'https://img1.baidu.com/it/u=1231971484,2328276513&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=674',
            'https://img0.baidu.com/it/u=151687053,1458872606&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=450',
            'http://t13.baidu.com/it/u=355305039,3195514550&fm=224&app=112&f=JPEG?w=500&h=500'
        ],
        introduce: '是一些高数等书籍材料',
        price: '20',
        userCloudID: '1002'
    },
    {
        id: '21',
        title: '出售一台笔记本',
        //商品图片
        image: [
            'https://img0.baidu.com/it/u=2494186312,2688692480&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=550',
            'https://img1.baidu.com/it/u=1058684484,1576085109&fm=253&fmt=auto&app=138&f=JPEG?w=667&h=500',
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg6.baixing.net%2F8ab0b712c0616f19bfdb2bbc33512e83.jpg_xl&refer=http%3A%2F%2Fimg6.baixing.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673183725&t=1ae2542d823bc4e9ad39c0944db42971',
            'https://img1.baidu.com/it/u=4075857316,718479543&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=375'
        ],
        introduce: '因为打算换电脑了，这台笔记本就用不着出售了,便宜卖，价格好商量',
        price: '2499.99',
        userCloudID: '1000'
    },
    {
        id: '22',
        title: '出售一双穿过一次的鞋子',
        image: [
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.alicdn.com%2Fbao%2Fuploaded%2Fi3%2F3221079748%2FO1CN01x06e4W2LsdY7lkkXg_%21%210-item_pic.jpg&refer=http%3A%2F%2Fimg.alicdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673184010&t=7b6cf95438def07a93812f6120afce65',
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg10.360buyimg.com%2Fn1%2Fjfs%2Ft1%2F189114%2F39%2F22272%2F197959%2F624313cbEccbcd4cd%2F29cfc3bb398cc0d4.jpg&refer=http%3A%2F%2Fimg10.360buyimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673183906&t=6777fa5f894ee9a85a4d541e90e14c08',
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimgservice.suning.cn%2Fuimg1%2Fb2c%2Fimage%2FsBRCXs6rNIgnKG0YgY2vPA.jpg_800w_800h_4e&refer=http%3A%2F%2Fimgservice.suning.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673183970&t=754842f2f98222ee507001975ce1053a',
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.alicdn.com%2Fbao%2Fuploaded%2Fi3%2F3221079748%2FO1CN01x06e4W2LsdY7lkkXg_%21%210-item_pic.jpg&refer=http%3A%2F%2Fimg.alicdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673183970&t=cfec992c7b288258a983b569041162cc'
        ],
        introduce: '只穿过一次，99新，具有纪念意义，价格好商量',
        price: '141.99',
        userCloudID: '1000'
    }
];

//当前用户信息
var user = {
    userName: '点击登录',
    userImage: '/static/images/head_img.png',
    cloudID: ''
};

//用户信息列表
var userList = [
    {
        cloudID: '1000',
        userName: '心动旋律',
        userImage: 'https://img2.baidu.com/it/u=2595110309,3837241641&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
    },
    {
        cloudID: '1001',
        userName: '小李子',
        userImage: 'https://img0.baidu.com/it/u=3791344154,3424644102&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
    },
    {
        cloudID: '1002',
        userName: '傻傻的男孩',
        userImage: 'https://img2.baidu.com/it/u=1985440899,2791731152&fm=253&fmt=auto&app=120&f=JPEG?w=200&h=200'
    },
    {
        cloudID: '1003',
        userName: '转身、说再见',
        userImage: 'https://pics2.baidu.com/feed/0e2442a7d933c8958c6ea8eace271af8830200ce.jpeg?token=4d7411a78e1232304310cf3f15fb3f5c'
    },
    {
        cloudID: '1004',
        userName: '老温酒',
        userImage:
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F13244909409%2F1000&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673179069&t=8515d375a027efd55dc40ab037be8ae4'
    },
    {
        cloudID: '1005',
        userName: '与温暖终年不遇',
        userImage: 'https://img2.baidu.com/it/u=3738977175,3641706345&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
    }
];

//添加用户
function addUser(user) {
    userList.push(user);
}

//评论列表
var commentList = [
    {
        //商品id
        id: '21',
        //消息列表
        commentListitem: [
            {
                sendoutid: '1003',
                acceptid: '',
                message: '价格能不能在底便宜点'
            },
            {
                sendoutid: '1002',
                acceptid: '',
                message: '感觉这个有些破损的地方呀，价格应该在便宜点'
            },
            {
                sendoutid: '1000',
                acceptid: '1003',
                message: '价格最低了，不能在便宜卖了'
            },
            {
                sendoutid: '1000',
                acceptid: '1002',
                message: '确实有些破损，但是价格真的不能在便宜卖了'
            }
        ]
    },
    {
        //商品id
        id: '22',
        //消息列表
        commentListitem: [
            {
                sendoutid: '1004',
                acceptid: '',
                message: '价格能不能在底便宜点'
            },
            {
                sendoutid: '1002',
                acceptid: '',
                message: '感觉这个有些破损的地方呀，价格应该在便宜点'
            },
            {
                sendoutid: '1000',
                acceptid: '1004',
                message: '价格最低了，不能在便宜卖了'
            },
            {
                sendoutid: '1000',
                acceptid: '1002',
                message: '确实有些破损，但是价格真的不能在便宜卖了'
            },
            {
                sendoutid: '1005',
                acceptid: '',
                message: '我想问一下这个鞋子是多少码的，看这款式，感觉还不错'
            },
            {
                sendoutid: '1000',
                acceptid: '1005',
                message: '鞋子是39码的，款式都是我很喜欢的'
            }
        ]
    }
];

//使用ID获取用户名字
function getIdUser(cloudID) {
    var str = '';
    for (let i = 0; i < userList.length; i++) {
        let index = userList[i];
        if (index.cloudID == cloudID) {
            str = index.userName;
            break;
        }
    }
    return str;
}
//返回不同商品信息
function getDatacommodity(id) {
    var obj = {
        //用户信息
        user: {},
        //商品详情
        details: {},
        //评论
        comment: []
    };
    for (let i = 0; i < commodityListData.length; i++) {
        if (commodityListData[i].id == id) {
            var index = commodityListData[i];
            obj.details = index;
            for (let j = 0; j < userList.length; j++) {
                if (index.userCloudID == userList[j].cloudID) {
                    obj.user.userName = userList[j].userName;
                    obj.user.userImage = userList[j].userImage;
                    break;
                }
            }
            for (let k = 0; k < commentList.length; k++) {
                var msg = commentList[k];
                if (msg.id == id) {
                    var messageitem = {};
                    for (let n = 0; n < msg.commentListitem.length; n++) {
                        messageitem = {};
                        var item = msg.commentListitem[n];
                        var str = getIdUser(item.sendoutid);
                        if (item.acceptid != '') {
                            str += ' 回复 ' + getIdUser(item.acceptid);
                        }
                        messageitem.reply = str;
                        messageitem.message = item.message;
                        obj.comment.push(messageitem);
                    }
                    break;
                }
            }
            return obj;
        }
    }
}

//返回评论数据
function getCommentList(id) {
    var comment = [];
    for (let k = 0; k < commentList.length; k++) {
        var msg = commentList[k];
        if (msg.id == id) {
            var messageitem = {};
            for (let n = 0; n < msg.commentListitem.length; n++) {
                messageitem = {};
                var item = msg.commentListitem[n];
                var str = getIdUser(item.sendoutid);
                if (item.acceptid != '') {
                    str += ' 回复 ' + getIdUser(item.acceptid);
                }
                messageitem.reply = str;
                messageitem.message = item.message;
                comment.push(messageitem);
            }
            return comment;
        }
    }
}

//更改用户信息
function setUser(data) {
    this.user = data;
}

//添加评论信息
function addCommentListitem(id, commentListitem) {
    let flag = true;
    for (let i = 0; i < commentList.length; i++) {
        var index = commentList[i];
        if (index.id == id) {
            index.commentListitem.push(commentListitem);
            flag = false;
            break;
        }
    }
    if (flag) {
        let arr = {
            id: id,
            commentListitem: [commentListitem]
        };
        commentList.push(arr);
    }
}

//添加商品
function addContent(obj) {
    this.commodityListData.push(obj);
}

//批量获取商品数据
function getcommodityListDataItem(pageIndex) {
    let leng = commodityListData.length;
    let n = 10;
    if (leng % n == 0) {
        let size = leng / n;
    } else {
        let size = parseInt(leng / n + 1);
    }
    if (pageIndex > size) {
        return;
    }
    let obj = [];
    if (pageIndex == size) {
        for (let i = n - (pageIndex * n - leng) - 1; i >= 0; i--) {
            obj.push(commodityListData[i]);
        }
    } else {
        for (let i = leng - (pageIndex - 1) * n - 1; i >= leng - pageIndex * n; i--) {
            obj.push(commodityListData[i]);
        }
    }
    return obj;
}
export { commodityListData, user, userList, getDatacommodity, setUser, addCommentListitem, getCommentList, addUser, addContent, getcommodityListDataItem };
